package com.example.win.android_banduyujia.peopleactivity.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.TextView;

import com.example.win.android_banduyujia.R;
import com.example.win.android_banduyujia.peopleactivity.adapter.GridViewAdapter;
import com.example.win.android_banduyujia.entity.Model;
import com.example.win.android_banduyujia.entity.Type;

import java.util.ArrayList;

/**
 * Created by huchun on 2015/9/5.
 */
public class ProTypeFragment extends Fragment {

    private ArrayList<Type>  list;
    private GridView    gridView;
    private GridViewAdapter adapter;
    private Type   type;
    private String    typename;
    private String icon;

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

       View  view = inflater.inflate(R.layout.fragemnt_city_list_page, null);

        gridView = (GridView)view.findViewById(R.id.grid_view_city);
        int  index = getArguments().getInt("index");

        typename = Model.SCOPE_CITY_BEIJING[index];
        icon = Model.SCOPR_CITY_BEIJING_ITEM[index];

        ((TextView)view.findViewById(R.id.fragment_list_top_type)).setText(typename);
        GetTypeList();
        adapter = new GridViewAdapter(getActivity(), list);
        gridView.setAdapter(adapter);
        gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {


            }
        });
        return view;
    }

    private void GetTypeList() {
        list = new ArrayList<Type>();
        for (int  i=0;i<20;i++){
            type = new Type(i, typename + i,icon);
            list.add(type);
        }
    }
}
